export default function registerFamen (lf) {
  lf.register('famen', ({ CircleNode, CircleNodeModel, h }) => {
    class EndNode extends CircleNode {
      getIconShape () {
        const attributes = this.getAttributes()
        const {
          x,
          y,
          width,
          height
        } = attributes
        return h(
          'svg',
          {
            x: x - width / 2,
            y: y - height / 2,
            width: 40,
            height: 40,
            viewBox: '0 0 1024 1024'
          },
          h(
            'path',
            {
              fill: '#1296db',
              d: 'M659.413333 640h40.704c7.765333-1.92 15.509333-9.706667 15.509334-17.450667V469.333333c-1.92-7.765333-9.685333-13.568-19.392-13.568h-40.725334a18.624 18.624 0 0 0-13.568 17.450667v151.274667c1.92 9.685333 9.685333 15.509333 17.450667 15.509333zM362.666667 455.765333h-40.725334a18.624 18.624 0 0 0-13.568 17.450667v151.274667c1.92 7.744 9.685333 13.568 17.450667 13.568h40.725333c7.744-1.92 15.509333-9.685333 15.509334-17.450667v-153.216c-1.92-5.824-9.685333-11.626667-19.392-11.626667z'
            }
          ),
          h(
            'path',
            {
              fill: '#1296db',
              d: 'M577.92 752.490667H349.12L160.96 704V391.765333l186.197333-46.549333L405.333333 287.04l1.92-1.941333c1.962667-1.941333 1.962667-3.882667 1.962667-5.824 0-1.941333 0-5.824-1.941333-5.824-1.941333-1.92-3.882667-1.92-5.824-1.92h-48.490667 48.490667-56.234667l-7.765333 1.92-215.253334 54.314666h-1.962666l-7.744 3.861334C95.04 339.413333 85.333333 358.784 85.333333 380.117333V725.333333c1.92 19.413333 15.509333 34.901333 32.96 42.666667l7.765334 1.92 11.648 3.904 5.802666 1.92 5.824 1.962667 184.234667 48.469333h1.941333l7.765334 1.941333h186.176l56.256-56.234666c1.92-1.941333 3.861333-3.882667 3.861333-7.765334-1.92-7.744-5.802667-11.626667-11.626667-11.626666zM938.666667 380.117333c0-19.392-9.706667-36.842667-25.216-46.549333l-5.824-3.861333-3.861334-1.941334-3.882666-1.941333-207.509334-54.314667h-1.941333l-7.765333-1.92H630.314667a10.666667 10.666667 0 0 1-5.824-9.706666v-1.941334c0-1.941333 1.92-3.882667 1.92-5.824 15.530667-32.96 50.432-100.842667 58.197333-116.352 0-1.941333 1.92-1.941333 1.92-3.882666 0-3.882667-1.92-5.824-3.861333-7.765334-1.92-1.92-5.824-1.92-9.706667 0l-64 34.922667-108.586667 110.528 7.744-7.744-15.509333 15.509333 1.92-1.92-36.821333 36.821334c-5.824 5.824-7.765333 13.589333-3.882667 19.413333 1.92 7.744 9.685333 11.626667 17.450667 11.626667h207.509333l188.117333 48.490666V704l-186.176 48.490667L622.549333 810.666667l-1.941333 1.92c-1.941333 1.962667-1.941333 5.845333 0 9.706666 1.92 3.882667 5.824 3.882667 7.765333 3.882667H682.666667l7.765333-1.92 192-50.432h1.92l13.589333-3.882667 5.824-1.941333c21.333333-7.765333 34.901333-29.098667 34.901334-52.373333V380.16z'
            }
          )
        )
      }
      getShape () {
        const attributes = this.getAttributes()
        const {
          x,
          y,
          r,
          fill,
          stroke,
          strokeWidth
        } = attributes
        return h(
          'g',
          {
          },
          [
            h(
              'circle',
              {
                cx: x,
                cy: y,
                r,
                fill,
                stroke,
                strokeWidth
              }
            ),
            this.getIconShape()
          ]
        )
      }
    }
    class EndModel extends CircleNodeModel {
      constructor (data, graphModel) {
        data.text = {
          value: (data.text && data.text.value) || '网关',
          x: data.x,
          y: data.y + 35
        }
        super(data, graphModel)
      }
    }
    return {
      view: EndNode,
      model: EndModel
    }
  })
}
